#ifndef	SUDOKU_BOARD_H
#define	SUDOKU_BOARD_H

#include <vector>
#include <list>
#include <map>
#include <set>
#include <boost/foreach.hpp>
#include <ctime>
#include <cstdio>

#include "sudoku_field.h"
#include "sudoku_algorithm.h"
#include "sudoku_definition.h"
//------------------------------------------------------------------------------------------------------------
class SudokuField;
class SudokuDefinition;
class SudokuSolvingAlgorithm;

typedef std::pair<int,SudokuField*> int_sf_pair;

using namespace std;
//------------------------------------------------------------------------------------------------------------
class SudokuBoard {
	public:
		SudokuBoard(SudokuSolvingAlgorithm* pSudAlgo, SudokuDefinition* pSudDef, std::map<int,int>* initialSudoku);
		SudokuBoard(SudokuSolvingAlgorithm* pSudAlgo, SudokuDefinition* pSudDef, char* fileName);
		map<int,SudokuField*>* getBoard() {return &sudokuBoard;} //TODO: return constant; impossible change of elements
        std::map<int,SudokuField*>::iterator it;
        void updateAvailableSet(SudokuField* f);
        void snapshot();
        vector<map<int,int>*>* getSolutions() {return &solutions;}
        int getMaxsol() {return maxSol;};
        void print();
        void startSolving(int maxSol);
		int laps;
	private:
		//bool fieldCompare(SudokuField* f1, SudokuField* f2);
        map<int,SudokuField*> sudokuBoard;
        vector<map<int,int>*> solutions;
        int maxSol;
        map<int,vector<Group*>*> groupsByField; //groups by fields
        SudokuSolvingAlgorithm* sudAlgo;
        SudokuDefinition* sudDef;
        std::map<int,int> initialSudoku;
        void fetchSudokuInit(); //fetching from file - init and size of board
        char* fileName; //init sudoku file
        list<SudokuField*> fieldsOrderedBySize;
        void init();
};
//------------------------------------------------------------------------------------------------------------
#endif


